package com.openbravo.beans;

import com.openbravo.editor.JEditorDoublePositive;
import com.openbravo.editor.JEditorKeys;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.SwingUtilities;

public class JNumberDialog extends JDialog
{
  private static LocaleResources m_resources;
  private Double m_value;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JPanel jPanel3;
  private JPanel jPanel4;
  private JPanel jPanelGrid;
  private JButton jcmdCancel;
  private JButton jcmdOK;
  private JEditorKeys m_jKeys;
  private JPanel m_jPanelTitle;
  private JEditorDoublePositive m_jnumber;
  private JLabel m_lblMessage;

  public JNumberDialog(Frame paramFrame, boolean paramBoolean)
  {
    super(paramFrame, paramBoolean);
    init();
  }

  public JNumberDialog(Dialog paramDialog, boolean paramBoolean)
  {
    super(paramDialog, paramBoolean);
    init();
  }

  private void init()
  {
    if (m_resources == null)
    {
      m_resources = new LocaleResources();
      m_resources.addBundleName("beans_messages");
    }
    initComponents();
    getRootPane().setDefaultButton(this.jcmdOK);
    this.m_jnumber.addEditorKeys(this.m_jKeys);
    this.m_jnumber.reset();
    this.m_jnumber.setDoubleValue(Double.valueOf(0.0D));
    this.m_jnumber.activate();
    this.m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
    this.m_value = null;
  }

  private void setTitle(String paramString1, String paramString2, Icon paramIcon)
  {
    setTitle(paramString1);
    this.m_lblMessage.setText(paramString2);
    this.m_lblMessage.setIcon(paramIcon);
  }

  public static Double showEditNumber(Component paramComponent, String paramString)
  {
    return showEditNumber(paramComponent, paramString, null, null);
  }

  public static Double showEditNumber(Component paramComponent, String paramString1, String paramString2)
  {
    return showEditNumber(paramComponent, paramString1, paramString2, null);
  }

  public static Double showEditNumber(Component paramComponent, String paramString1, String paramString2, Icon paramIcon)
  {
    Window localWindow = SwingUtilities.windowForComponent(paramComponent);
    JNumberDialog localJNumberDialog;
    if ((localWindow instanceof Frame))
      localJNumberDialog = new JNumberDialog((Frame)localWindow, true);
    else
      localJNumberDialog = new JNumberDialog((Dialog)localWindow, true);
    localJNumberDialog.setTitle(paramString1, paramString2, paramIcon);
    localJNumberDialog.setVisible(true);
    return localJNumberDialog.m_value;
  }

  private void initComponents()
  {
    this.jPanel1 = new JPanel();
    this.jcmdOK = new JButton();
    this.jcmdCancel = new JButton();
    this.jPanel2 = new JPanel();
    this.jPanelGrid = new JPanel();
    this.jPanel3 = new JPanel();
    this.m_jKeys = new JEditorKeys();
    this.jPanel4 = new JPanel();
    this.m_jnumber = new JEditorDoublePositive();
    this.m_jPanelTitle = new JPanel();
    this.m_lblMessage = new JLabel();
    setResizable(false);
    addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent paramWindowEvent)
      {
        JNumberDialog.this.formWindowClosing(paramWindowEvent);
      }
    });
    this.jPanel1.setLayout(new FlowLayout(2));
    this.jcmdOK.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/button_ok.png")));
    this.jcmdOK.setText(m_resources.getString("button.ok"));
    this.jcmdOK.setMargin(new Insets(8, 16, 8, 16));
    this.jcmdOK.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JNumberDialog.this.jcmdOKActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.jcmdOK);
    this.jcmdCancel.setIcon(new ImageIcon(getClass().getResource("/com/openbravo/images/button_cancel.png")));
    this.jcmdCancel.setText(m_resources.getString("button.cancel"));
    this.jcmdCancel.setMargin(new Insets(8, 16, 8, 16));
    this.jcmdCancel.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JNumberDialog.this.jcmdCancelActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.jcmdCancel);
    getContentPane().add(this.jPanel1, "South");
    this.jPanel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.jPanel2.setLayout(new BorderLayout());
    this.jPanel3.setLayout(new BoxLayout(this.jPanel3, 1));
    this.jPanel3.add(this.m_jKeys);
    this.jPanel4.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.jPanel4.setLayout(new BorderLayout());
    this.jPanel4.add(this.m_jnumber, "Center");
    this.jPanel3.add(this.jPanel4);
    this.jPanelGrid.add(this.jPanel3);
    this.jPanel2.add(this.jPanelGrid, "Center");
    getContentPane().add(this.jPanel2, "Center");
    this.m_jPanelTitle.setLayout(new BorderLayout());
    this.m_lblMessage.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.darkGray), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    this.m_jPanelTitle.add(this.m_lblMessage, "Center");
    getContentPane().add(this.m_jPanelTitle, "North");
    Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((localDimension.width - 253) / 2, (localDimension.height - 433) / 2, 253, 433);
  }

  private void jcmdOKActionPerformed(ActionEvent paramActionEvent)
  {
    this.m_value = this.m_jnumber.getDoubleValue();
    setVisible(false);
    dispose();
  }

  private void jcmdCancelActionPerformed(ActionEvent paramActionEvent)
  {
    setVisible(false);
    dispose();
  }

  private void formWindowClosing(WindowEvent paramWindowEvent)
  {
    setVisible(false);
    dispose();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.beans.JNumberDialog
 * JD-Core Version:    0.6.0
 */